<template>
  <div>
      <el-table
        :data="tableData"
        border
        style="width: 100%">
        <el-table-column
          prop="name"
          label="姓名"
          width="180">
        </el-table-column>
        <el-table-column
          prop="phone"
          label="手机号"
          width="100">
        </el-table-column>
        <el-table-column
          prop="email"
          label="邮箱"
          width="100">
        </el-table-column>
        <el-table-column
          prop="address"
          label="地址">
        </el-table-column>
        <el-table-column
          prop="createTime"
          label="日期"
          width="100">
        </el-table-column>
      </el-table>
    <el-pagination
      background
      align="right"
      layout="prev, pager, next"
      :total="total"
      :page-size="pageSize"
      :current-page="currentPage"
      :page-count="pageCount"
      @current-change="toPage">
    </el-pagination>
  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData: [],
      pageSize: 5,
      currentPage: 1,
      total: 0,
      pageCount: 1,
    }
  },
  methods:{
    getTableData(){
      let params = {"currentPage": this.currentPage,"pageSize": this.pageSize}
      this.$http.post("/user/list",params).then(res =>{
        this.tableData = res.data.data
        this.total = res.data.totals
      })
    },
    toPage(curr){
      this.currentPage = curr
      this.getTableData()
    },
    mounted(){
      this.getTableData()
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>

</style>
